package com.itbaizhan.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WeatherController {

    @Autowired
    ChatModel chatModel;

    /**
     * 获取天气情况
     * @param city
     * @return
     */
    @GetMapping("/chat")
    public String weather(String city) {

        ChatClient chatClient = ChatClient.builder(chatModel)
                .defaultFunctions("getWeatherFuntion")
                .build();

        String content = chatClient.prompt().user(city).call().content();

        return content;


    }


}
